﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _3___Fractions
{
    class Fraction:IFormattable
    {
        int numerator;
        int denominator;

        public Fraction(int numerator, int denominator)
        {
            this.numerator = numerator;
            this.denominator = denominator;
        }

        public override string ToString()
        {
            return String.Format("{0:F}", numerator / denominator);
        }

        public string ToString(string format, IFormatProvider formatProvider)
        {
            if (format == "N")
            {
                return String.Format("{0}/{1}", numerator,denominator);
            }
            else if (format == "R")
            {
                return String.Format("{0:F2}", (double)numerator/denominator);
            }
            else
            {
                return String.Format("{0:F}", (double)numerator / denominator);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Fraction f = new Fraction(4, 37121);
            Console.WriteLine("{0:R}",f);
            Console.WriteLine(f);
        }
    }
}
